package com.javaspeak.designpatterns.go4.behavioural.templatemethod;

/**
 * The Template Method Pattern uses an abstract class. The abstract class
 * has a method ( called buildPage() in this example ) which calls the
 * abstract methods in the correct order.
 * <p>
 * The esact implementation of the abstract methods is left to sub classes
 * of the abstract class.
 * <p>
 * In this example AbstractHtmlPage is extended by the class HomePage to provide
 * implementation of the abstract methods, getTitle(), getHeader(),
 * getContent(), getFooter();
 *
 * @author John Dickerson
 */
public class ApplicationTemplateMethod {

    /**
     * Example demonstrating Template Method pattern
     *
     * Run example
     */
    private void runExample() throws FormatException {

        AbstractHtmlPage htmlPage = new HomePage();
        String html = htmlPage.getHtml();
        System.out.println( html );
    }


    public static void main(String[] args) throws FormatException {

        ApplicationTemplateMethod application = new ApplicationTemplateMethod();
        application.runExample();
    }
}
